package com.zc.web.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zc.common.utils.DateUtils;
import com.zc.web.domain.TodayGoal;
import com.zc.web.mapper.TodayGoalMapper;
import com.zc.web.service.ITodayGoalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * 今日目标Service业务层处理
 *
 * @author zc
 * @date 2025-09-29
 */
@Service
public class TodayGoalServiceImpl extends ServiceImpl<TodayGoalMapper, TodayGoal> implements ITodayGoalService
{
    @Autowired
    private TodayGoalMapper todayGoalMapper;

    /**
     * 查询今日目标
     *
     * @param id 今日目标主键
     * @return 今日目标
     */
    @Override
    public TodayGoal selectTodayGoalById(Long id)
    {
                return getById(id);
    }

    /**
     * 查询今日目标列表
     *
     * @param todayGoal 今日目标
     * @return 今日目标
     */
    @Override
    public List<TodayGoal> selectTodayGoalList(TodayGoal todayGoal)
    {
        return todayGoalMapper.selectTodayGoalList(todayGoal);
    }

    /**
     * 新增今日目标
     *
     * @param todayGoal 今日目标
     * @return 结果
     */
    @Override
    public int insertTodayGoal(TodayGoal todayGoal)
    {
                todayGoal.setCreateTime(DateUtils.getNowDate());
                        return save(todayGoal) == true? 1 : 0;
    }

    /**
     * 修改今日目标
     *
     * @param todayGoal 今日目标
     * @return 结果
     */
    @Override
    public int updateTodayGoal(TodayGoal todayGoal)
    {
                todayGoal.setUpdateTime(DateUtils.getNowDate());
                return updateById(todayGoal) == true ? 1 : 0;
    }

    /**
     * 批量删除今日目标
     *
     * @param ids 需要删除的今日目标主键
     * @return 结果
     */
    @Override
    public int deleteTodayGoalByIds(Long[] ids)
    {
                return removeByIds(Arrays.asList(ids)) == true ? 1 : 0;
    }

    /**
     * 删除今日目标信息
     *
     * @param id 今日目标主键
     * @return 结果
     */
    @Override
    public int deleteTodayGoalById(Long id)
    {
                return removeById(id) == true ? 1 : 0;
    }
}